﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Windows.Media.Imaging;

namespace DSA
{
    public partial class OfferListEntry : UserControl
    {

        public string ImageSource = "";

        public OfferListEntry()
        {
            InitializeComponent();
        }

        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
            PivotPage1 pg = frame.Content as PivotPage1;

            ListEntryItem item = new ListEntryItem();
            item.chkItemName.IsChecked = true;
            item.txtName.Text = txtProduct.Text;
            item.txtPrice.Text = txtPrice.Text;
            item.txtQuantity.Text = "x1";
            item.image.Source = new BitmapImage(new Uri(ImageSource, UriKind.Relative));
            item.ImageSource = ImageSource;

            pg.listboxItemList.Items.Add(item);
            pg._pivot.SelectedIndex = 0;
            pg.listboxItemList.SelectedIndex = pg.listboxItemList.Items.Count - 1;
            pg.listboxItemList.ScrollIntoView(pg.listboxItemList.SelectedItem);
        }
    }
}
